//获取应用实例
const app = getApp();
// 引入AES.js
var baseJs = require("../../common/base.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    // 
    uid: "",
    userType: "",
    // 修改
    typename: '',
    typeid: '',
    index: '',

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      uid: wx.getStorageSync('uid'),
      userType: wx.getStorageSync('userType'),
      typeid: options.TypeId,
    })
    console.log(options.TypeId);
  },
  //获取产品名称
  NameInput: function (e) {
    console.log(e)
    this.setData({
      typename: e.detail.value,
    })
  },
  // 修改
  formSubmit: function (e) {
    var that = this;
    var typename = this.data.typename;
    var typeid = this.data.typeid;
    console.log(typeid);
    console.log("method=BusinessUpdateCustomGoodsType&TypeName=" + typename + "&TypeId=" + typeid)
    wx.request({
      url: baseJs.api + baseJs.encryUrl("method=BusinessUpdateCustomGoodsType&TypeName=" + typename + "&TypeId=" + typeid),
      success: function (res) {
        var json = JSON.parse(baseJs.decryUrl(res.data));
        typename = json.ResultData.TypeName;
        typeid = json.ResultData.TypeId;
        console.log(json);

        if (json.ResultFlag == 1) {
          wx.showToast({
            title: json.ResultMsg,
            icon: 'none',
            duration: 2000
          });
          setTimeout(function () {
            wx.navigateBack({
              delta: 1
            })
          }, 1000)
        } else {
          wx.showToast({
            title: json.ResultMsg,
            icon: 'none',
            duration: 2000
          });
        }
      }
    })
  },
  
})